package com.donglink.project.logmonitor.bolt;

import com.donglink.project.logmonitor.domain.LogMonitorRuleRecord;
import com.donglink.project.logmonitor.utils.MonitorHandler;
import org.apache.storm.task.OutputCollector;
import org.apache.storm.task.TopologyContext;
import org.apache.storm.topology.IBasicBolt;
import org.apache.storm.topology.IRichBolt;
import org.apache.storm.topology.IWindowedBolt;
import org.apache.storm.topology.OutputFieldsDeclarer;
import org.apache.storm.topology.base.BaseRichBolt;
import org.apache.storm.tuple.Tuple;

import java.util.Map;

public class SaveBolt extends BaseRichBolt {
    @Override
    public void prepare(Map map, TopologyContext topologyContext, OutputCollector outputCollector) {

    }

    @Override
    public void execute(Tuple tuple) {

        //将所有到来的数据全部存入到数据库中
        LogMonitorRuleRecord logMonitorRuleRecord=(LogMonitorRuleRecord) tuple.getValue(0);


        MonitorHandler.saveRecordToSql(logMonitorRuleRecord);

    }

    @Override
    public void declareOutputFields(OutputFieldsDeclarer outputFieldsDeclarer) {

    }
}
